# open-cv library is installed as cv2 in python
# import cv2 library into this program
import cv2
import sys

if __name__ == '__main__':
    if len(sys.argv) != 3:
        print("Usage: " + sys.argv[0] + " image output|-")
        exit(1)

    img_path = sys.argv[1]
    if sys.argv[2] == '-':
        output = sys.argv[1]
    else:
        output = sys.argv[2]

    # read an image using imread() function of cv2
    # we have to  pass only the path of the image
    img = cv2.imread(img_path)

    HSV_img = cv2.cvtColor(img,cv2.COLOR_BGR2HSV)

    cv2.imwrite(output, HSV_img)

    H, S, V = cv2.split(HSV_img)

    cv2.imshow('H', H)
    cv2.imshow('S', S)
    cv2.imshow('V', V)

    cv2.imshow('HSV', HSV_img)

    sys.stdin.readline()